﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.IO;

namespace JasmineCore
{
	public class AtomWriter
	{
		// コンストラクタ
		public AtomWriter( TextWriter writer )
		{
			StringWriter strWiter = new StringWriter();
			XmlTextWriter xmlWriter = new XmlTextWriter( strWiter );
			try
			{
				xmlWriter.WriteStartDocument();
				xmlWriter.WriteStartElement( "a" );

				xmlWriter.WriteStartAttribute( "attribute1" );
				xmlWriter.WriteString( "Hello" );
				xmlWriter.WriteEndElement();

				xmlWriter.WriteAttributeString( "attribute2", "sample2" );

				xmlWriter.WriteStartElement( "b" );
				xmlWriter.WriteEndElement();

				xmlWriter.WriteString( "\r\n" );

				xmlWriter.WriteStartElement( "c" );
				xmlWriter.WriteString( "Hello2" );
				xmlWriter.WriteEndElement();

				xmlWriter.WriteElementString( "d", "sample4" );

				xmlWriter.WriteEndElement();

				xmlWriter.WriteWhitespace( "\r\n" );
				xmlWriter.WriteComment( "end of file" );

				xmlWriter.WriteEndDocument();
			}
			finally
			{
				xmlWriter.Close();
			}
		}
	}
}
